<div class="layuimini-main">
    <div class="layui-form layuimini-form">
        <input type="text" name="id" value="id" style="display: none;">
        <br>
        <div class="layui-form-item">
            <label class="layui-form-label ">反馈标题：</label>
            <div class="layui-input-block">
                <input type="text" id="title" class="layui-input" style="width:93%;color: rgb(156, 153, 153);" disabled="disabled">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label ">反馈人：</label>
            <div class="layui-input-block">
                <input type="text" id="sender" class="layui-input"  style="width:93%;color: rgb(156, 153, 153);" disabled="disabled">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label ">反馈时间：</label>
            <div class="layui-input-block">
                <input type="text" id="sendTime" class="layui-input"  style="width:93%;color: rgb(156, 153, 153);" disabled="disabled">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label ">反馈内容：</label>
            <div class="layui-input-block">
                <textarea name="text" id="text" class="layui-textarea" style="width:93%;height: 160px;;color: rgb(156, 153, 153);" disabled="disabled"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">选择状态：</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="0" title="未处理">
                <input type="radio" name="status" value="1" title="正在处理">
                <input type="radio" name="status" value="2" title="处理完成">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">回复内容：</label>
            <div class="layui-input-block">
                <textarea name="replyText" id="replyText" class="layui-textarea" placeholder="请输入回复内容"
                    style="width:93%;height:140px" spellcheck="false"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <!-- <button class="layui-btn" lay-submit lay-filter="saveBtn"
                    style="position:absolute;right:7%;bottom:2px;border:none;outline:none;width: 90px;height:32px">确认回复</button> -->
                    <button class="layui-btn" id="submit" lay-submit lay-filter="saveBtn" style="position:absolute;right:18%;bottom:2px;border:none;outline:none;width: 90px;height:32px;line-height:32px;
                    background-color: #FFB800;font-size: 14px;color: #ffffff;">确认回复</button>
                    <button class="layui-btn" onclick="closeEditorCommon();" type="button" style="position:absolute;right:8%;bottom:2px;border:none;outline:none;width: 90px;height:32px;line-height:32px;
                    background-color: #cccccc;font-size: 14px;color: #ffffff;">关闭</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        var parent_json = parent.editData,
            status = parent_json.status;
        $("input[name ='id']").val(parent_json.id)
        $("input[id ='title']").val(parent_json.title)
        $("input[id ='sender']").val(parent_json.sender)
        $("input[id ='sendTime']").val(parent_json.sendTime)
        $("textarea[name ='text']").val(parent_json.text)
        $("textarea[name ='replyText']").val(parent_json.replyText)
        if ("0" === status) { //未处理
            $("input[name='status']").get(0).checked = true;
        }else if ("1" === status) {  //正在处理
            $("input[name='status']").get(1).checked = true;
        }else if ("2" === status) { //已处理
            $("input[name='status']").get(2).checked = true;
        }
    });

    layui.use(['form', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;
        /**
         *   初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();
        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;
        //监听提交
        layui.form.on('submit(saveBtn)', function (data) {
            if (data.field.status)
                shared.ajaxPost('/admin/commons/updateCommons', data.field, function (res) {
                    refreshTable();
                })
            layer.close(parentIndex);
            return false;
        })

    });

    function refreshTable() {
        // var $ = layui.jquery,
        cols = [
            { align: 'center', title: '序号', type: 'numbers', width: '5%' },
            { field: 'id', title: 'ID', width: '8%', hide: true },
            { field: 'title', title: '标题', align: 'center', width: '20%' },
            { field: 'senderName', title: '发布用户', align: 'center', width: '10%' },
            { field: 'sender', title: '发送人ID', align: 'center', hide: true },
            { field: 'sendTime', title: '发布时间', align: 'center', width: '15%' },
            { field: 'status', title: '状态', align: 'center', width: '8%' ,templet: function(d){
            var t = d.status;
            if(t === "0"){
            return "未处理"
            }else if(t === "1"){
            return "正在处理"
            }else if(t === "2"){
            return "已处理"
            }
            }},
            { field: 'replierName', title: '回复人', align: 'center', width: '10%' },
            { field: 'replyTime', title: '回复时间', align: 'center', width: '15%' },
            { title: '操作', templet: '#currentTableBar', fixed: "right", align: "center" }
        ];

        layuiEx.tableRender('/admin/commons/queryCommons', 'currentTableId', 'page', cols, {
        page: 1,
        pageSize: 10,
        });
    }

       /** 设置关闭按钮的click事件处理 */
       function closeEditorCommon() {
        layer.confirm('确定丢弃编辑页面内容？', function (index) {
            layer.closeAll();
        });
    }
</script>